<template>
    <div>
        <el-row>
            <el-col :span="21"><el-input v-model="input" placeholder="任务详情" @keydown.enter="add()"/></el-col>
            <el-col :span="3"><el-button type="primary" @click="add()">添加任务</el-button></el-col>
        </el-row>
    </div>
</template>
<script>
export default {
    data(){
        return{
            input:''
        }
    },
    methods:{
        add(){
            // this.$emit("add",this.input)// 容错
            // this.input=''
            if(this.input){
                this.$emit("add",this.input)
            }else{
                alert('输入不能为空')
            }
        }
    }
}
</script>